/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.mail.manage.service;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import info.peigen.hotpot.component.mail.domain.MailTemplate;
import info.peigen.hotpot.component.mail.manage.service.order.MailTemplateCreateOrder;
import info.peigen.hotpot.component.mail.manage.service.order.MailTemplateDeleteOrder;
import info.peigen.hotpot.component.mail.manage.service.order.MailTemplateEditOrder;
import info.peigen.hotpot.component.mail.manage.controller.form.MailTemplateManageCreateForm;
import info.peigen.hotpot.component.mail.manage.controller.form.MailTemplateManageDeleteForm;
import info.peigen.hotpot.component.mail.manage.controller.form.MailTemplateManageEditForm;
import info.peigen.hotpot.component.mail.manage.service.result.info.MailTemplateManageInfo;
import info.peigen.hotpot.component.mail.repository.entity.MailTemplateEntity;

/**
 * <b>(MailTemplateManageConvertor)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/7
 */
public class MailTemplateManageConvertor {

    public static MailTemplateCreateOrder convertOrder(MailTemplateManageCreateForm form) {
        return BeanUtil.toBean(form, MailTemplateCreateOrder.class, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static MailTemplateEditOrder convertOrder(MailTemplateManageEditForm form) {
        return BeanUtil.toBean(form, MailTemplateEditOrder.class, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static MailTemplateDeleteOrder convertOrder(MailTemplateManageDeleteForm form) {
        return BeanUtil.toBean(form, MailTemplateDeleteOrder.class, CopyOptions.create().setIgnoreNullValue(true));
    }

    public static MailTemplateManageInfo convertToInfo(MailTemplate domain) {
        return BeanUtil.copyProperties(domain, MailTemplateManageInfo.class);
    }

    public static MailTemplateManageInfo convertToInfo(MailTemplateEntity entity) {
        return BeanUtil.copyProperties(entity, MailTemplateManageInfo.class);
    }

    public static MailTemplate convertToDomain(MailTemplateEntity entity) {
        return BeanUtil.copyProperties(entity, MailTemplate.class);
    }
}